import { TOKEN_KEY } from '@/enums/cacheEnums';
import { resetRouter } from '@/router';
import useTabsStore from '@/stores/modules/multipleTabs';
import useUserStore from '@/stores/modules/user';

import cache from './cache';

export function clearAuthInfo() {
  const userStore = useUserStore();
  const tabsStore = useTabsStore();
  userStore.resetState();
  tabsStore.resetState();
  cache.remove(TOKEN_KEY);
  resetRouter();
}

export function getToken() {
  return cache.get(TOKEN_KEY);
}
